package edu.avans.hartigehap.domain;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Transient;

@Entity
public class AuthenticationSecurity extends WebCustomer implements Serializable{
	private static final long serialVersionUID = 1L;
	
	ActualWebCustomer _actualCustomer;
	
	public AuthenticationSecurity(String username, String password, List<ActualWebCustomer> accounts){
		for(ActualWebCustomer account : accounts){
			if(username.equals(account.getUsername()) && password.equals(account.getPassword())){
				_actualCustomer = account;
				break;
			}
		}
	}
	
	public AuthenticationSecurity(ActualWebCustomer actualCustomer){
		this._actualCustomer = actualCustomer;
	}
	
	@Override
	public String getFirstName() {
		return null;
	}
	@Override
	public void setFirstName(String firstName) {
		
	}
	@Override
	public String getLastName() {
		return null;
	}
	@Override
	public void setLastName(String lastName) {
		
	}
	@Override
	public String getEmailadress() {
		return null;
	}
	@Override
	public void setEmailadress(String emailadress) {
		
	}
	@Override
	public String getAddress() {
		return null;
	}
	@Override
	public void setAddress(String address) {
		
	}
	@Override
	public String getPhoneNumber() {
		return null;
	}
	@Override
	public void setPhoneNumber(String phoneNumber) {
		
	}

	@Override
	public String getUsername() {
		try{
			return _actualCustomer.getUsername();
		}catch(Exception e){
			return "error";
		}
	}

	@Override
	public String getPassword() {
		try{
			return _actualCustomer.getPassword();
		}catch(Exception e){
			return "error";
		}
	}

	@Override
	public boolean getLoggedIn() {
		try{
			return _actualCustomer.getLoggedIn();
		}catch(Exception e){
			return false;
		}
	}

	@Override
	public void setLoggedIn(boolean logged) {
		try{
			_actualCustomer.setLoggedIn(logged);
		}catch(Exception e){
			
		}		
	}

	@Override
	@Transient
	public void setUsername(String username) {
		
	}

	@Override
	@Transient
	public void setPassword(String password) {
		
	}
}
